package com.ourcraft.informationcollectionsystem.entity;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.sql.Date;

import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@TableName("InvestigationPeriod")
public class InvestigationPeriod {
    @TableId(type = IdType.AUTO)
    private Integer investigationId;
    private Integer patternId;
    private String investigationTitle;
    private Date investigationStartDate;
    private Integer investigationLength;
    private String investigationDescription;

//    @TableField(exist = false)
//    public Integer noSubmitNum;
//    @TableField(exist = false)
//    public Integer noExamineNum;
//    @TableField(exist = false)
//    public Integer examineNum;
//    @TableField(exist = false)
//    public Integer decreaseNum;

    public InvestigationPeriod(Integer patternId, String investigationTitle, Date investigationStartDate, int investigationLength, String investigationDescription) {
        this.patternId = patternId;
        this.investigationTitle = investigationTitle;
        this.investigationStartDate = investigationStartDate;
        this.investigationLength = investigationLength;
        this.investigationDescription = investigationDescription;
    }

    // 需要将前端的‘2023-11-4’的字符串日期转化为sql.Date
    public InvestigationPeriod(JSONObject param) {
        this.investigationId = param.getInteger("investigationId");
        this.patternId = param.getInteger("patternId");
        this.investigationTitle = param.getString("investigationTitle");
        this.investigationLength = param.getInteger("investigationLength");
        this.investigationDescription = param.getString("investigationDescription");
        this.investigationStartDate = Date.valueOf(param.getString("investigationStartDate"));
    }
}
